home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 183 / dpcs0503.iso / Components / Connector for iCat Commerce Online / data1.cab / Program_Executable_Files / iCat.jar / iCat / iCatAffiliate.class (.txt) next >
Encoding:
Java Class File  |  1998-11-13  |  5.2 KB  |  155 lines

  1. package iCat;
  2.  
  3. import com.netobjects.nfc.api.CStringArray;
  4. import com.netobjects.nfc.api.ComponentApp;
  5. import com.netobjects.nfc.api.DAssetManager;
  6. import com.netobjects.nfc.api.DDrawPicture;
  7. import com.netobjects.nfc.api.DFile;
  8. import com.netobjects.nfc.api.DImage;
  9. import com.netobjects.nfc.api.DLayout;
  10. import com.netobjects.nfc.api.DMessageBox;
  11. import com.netobjects.nfc.api.DRect;
  12. import com.netobjects.nfc.api.DSite;
  13. import com.netobjects.nfc.api.DSize;
  14. import com.netobjects.nfc.api.IDInspector;
  15.  
  16. public class iCatAffiliate extends ComponentApp {
  17.    String strImageFile = "";
  18.    String strStoreURL = "";
  19.    String strAffiliate = "";
  20.    int Image;
  21.    DDrawPicture cdp;
  22.    String codebase = "";
  23.    DAssetManager assetMan;
  24.  
  25.    public void onCopy() {
  26.       this.assetMan.CopyAsset(this.Image);
  27.    }
  28.  
  29.    protected void finalize() {
  30.       this.assetMan.RemoveAsset(this.Image);
  31.       this.strImageFile = null;
  32.       this.strStoreURL = null;
  33.       this.strAffiliate = null;
  34.       this.cdp = null;
  35.       this.codebase = null;
  36.       this.assetMan = null;
  37.    }
  38.  
  39.    public void onUnInstall(DAssetManager var1) {
  40.    }
  41.  
  42.    public String onInstall(DAssetManager var1, String var2) {
  43.       this.assetMan = var1;
  44.       this.codebase = var2;
  45.       this.strImageFile = this.codebase + "\\iCatAffiliate.gif";
  46.       return "iCat Affiliate";
  47.    }
  48.  
  49.    public void onInspect(CStringArray var1, CStringArray var2) {
  50.       var1.Set("Affiliate Code");
  51.       var2.Set("String");
  52.       var1.Set("Store URL");
  53.       var2.Set("String");
  54.       var1.Set("Image");
  55.       var2.Set("Image");
  56.    }
  57.  
  58.    public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) {
  59.       if (var3 == 1) {
  60.          if (var1.compareTo("Affiliate Code") == 0) {
  61.             return this.strAffiliate;
  62.          }
  63.  
  64.          if (var1.compareTo("Store URL") == 0) {
  65.             return this.strStoreURL;
  66.          }
  67.  
  68.          if (var1.compareTo("Image") == 0) {
  69.             return Integer.toString(this.Image);
  70.          }
  71.       } else {
  72.          if (var1.compareTo("Affiliate Code") == 0) {
  73.             this.strAffiliate = var2;
  74.          } else if (var1.compareTo("Store URL") == 0) {
  75.             this.strStoreURL = var2;
  76.             if (this.strStoreURL.length() != 0) {
  77.                this.writeiCatFile(this.strStoreURL);
  78.             }
  79.          } else if (var1.compareTo("Image") == 0) {
  80.             this.assetMan.RemoveAsset(this.Image);
  81.             this.Image = Integer.parseInt(var2, 10);
  82.             this.strImageFile = this.assetMan.GetAssetLocation(this.Image, 1, 1);
  83.             DImage var6 = new DImage();
  84.             var6.setImageFile(this.strImageFile);
  85.             DSize var7 = var6.getSize();
  86.             this.cdp.SetSize(var7.getWidth(), var7.getHeight());
  87.             this.cdp.setImageFile(this.assetMan.GetAssetLocation(this.Image, -1, 1));
  88.          }
  89.  
  90.          this.cdp.Invalidate(true);
  91.       }
  92.  
  93.       if (var5 != null) {
  94.          var5.OnPropertyChanged(-1);
  95.       }
  96.  
  97.       return "";
  98.    }
  99.  
  100.    public void onDrop(DLayout var1, DRect var2, int var3) {
  101.       if (var3 == 1) {
  102.          this.cdp = new DDrawPicture();
  103.          this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getRight(), var2.getBottom());
  104.          this.cdp.SetStyle(1, 1);
  105.          this.cdp.setStretch(2);
  106.          this.cdp.setUsePictureText(false);
  107.          DImage var4 = new DImage();
  108.          var4.setImageFile(this.strImageFile);
  109.          DSize var5 = var4.getSize();
  110.          this.cdp.SetSize(var5.getWidth(), var5.getHeight());
  111.          this.cdp.setImageFile(this.strImageFile);
  112.          var1.AddObject(this.cdp);
  113.       }
  114.    }
  115.  
  116.    public void onPublish(DAssetManager var1, int var2) {
  117.       String var3 = "<A HREF=\"http://www.icat.com/jump/";
  118.       if (this.strAffiliate.length() != 0) {
  119.          var3 = var3 + this.strAffiliate + "\">";
  120.       } else {
  121.          DMessageBox var4 = new DMessageBox();
  122.          var4.Warning("The Affiliate Code property of the iCatAffiliate component is not filled in.\r\nPlease enter this value and republish your site.\r\n");
  123.          var3 = var3 + "\" target=\"_top\" >";
  124.       }
  125.  
  126.       this.cdp.setAltTag("Build your own iCat store.");
  127.       this.cdp.setHTMLBefore(var3);
  128.       this.cdp.setHTMLAfter("</A>");
  129.       if (this.strStoreURL.length() == 0) {
  130.          DMessageBox var6 = new DMessageBox();
  131.          var6.Warning("The Store URL property of the iCatAffiliate component MUST be filled in.\r\nPlease enter this value and republish your site.\r\n");
  132.       }
  133.  
  134.    }
  135.  
  136.    public void writeiCatFile(String var1) {
  137.       DSite var2 = new DSite();
  138.       String var3 = var2.getName();
  139.       DFile var4 = new DFile();
  140.       if (var4.Open(this.codebase + "\\iCatInfo\\" + var3 + ".txt", 4097)) {
  141.          var4.Seek(0, 0);
  142.          var4.WriteString(var1, -1);
  143.          var4.Close();
  144.       } else {
  145.          DMessageBox var5 = new DMessageBox();
  146.          var5.Warning("The file (" + this.codebase + "iCatInfo\\" + var3 + ".txt) could not be created.\r\n" + "Without this file the iCat components will not publish correctly.\r\n");
  147.       }
  148.    }
  149.  
  150.    private void debug(String var1) {
  151.       DMessageBox var2 = new DMessageBox();
  152.       var2.Warning(var1 + "\r\n");
  153.    }
  154. }
  155.